#!/bin/sh
local_ip=` ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|grep -v 10.8|awk '{print $2}'|tr -d "addr:"`
echo "本机IP是:$local_ip"
iptables -t nat -A PREROUTING -d 10.0.0.2 -p tcp -m tcp --dport 31400 -j DNAT --to-destination 10.8.0.2:31400
iptables -t nat -A PREROUTING -d 10.0.0.2 -p tcp -m tcp --dport 31401 -j DNAT --to-destination 10.8.0.2:31401
iptables -t nat -A PREROUTING -d 10.0.0.2 -p tcp -m tcp --dport 31402 -j DNAT --to-destination 10.8.0.2:31402
iptables -t nat -A PREROUTING -d 10.0.0.2 -p tcp -m tcp --dport 31403 -j DNAT --to-destination 10.8.0.2:31403
iptables -t nat -A PREROUTING -d 10.0.0.2 -p tcp -m tcp --dport 31404 -j DNAT --to-destination 10.8.0.2:31404
iptables -t nat -A PREROUTING -d 10.0.0.2 -p tcp -m tcp --dport 31405 -j DNAT --to-destination 10.8.0.2:31405
iptables -t nat -A PREROUTING -d 10.0.0.2 -p tcp -m tcp --dport 31406 -j DNAT --to-destination 10.8.0.2:31406
iptables -t nat -A PREROUTING -d 10.0.0.2 -p tcp -m tcp --dport 31408 -j DNAT --to-destination 10.8.0.2:31407
iptables -t nat -A PREROUTING -d 10.0.0.2 -p tcp -m tcp --dport 31409 -j DNAT --to-destination 10.8.0.2:31409
iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -d 10.8.0.2 -p tcp -m tcp --dport 31400 -j SNAT --to-source 10.8.0.1
iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -d 10.8.0.2 -p tcp -m tcp --dport 31401 -j SNAT --to-source 10.8.0.1
iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -d 10.8.0.2 -p tcp -m tcp --dport 31402 -j SNAT --to-source 10.8.0.1
iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -d 10.8.0.2 -p tcp -m tcp --dport 31403 -j SNAT --to-source 10.8.0.1
iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -d 10.8.0.2 -p tcp -m tcp --dport 31404 -j SNAT --to-source 10.8.0.1
iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -d 10.8.0.2 -p tcp -m tcp --dport 31405 -j SNAT --to-source 10.8.0.1
iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -d 10.8.0.2 -p tcp -m tcp --dport 31406 -j SNAT --to-source 10.8.0.1
iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -d 10.8.0.2 -p tcp -m tcp --dport 31407 -j SNAT --to-source 10.8.0.1
iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -d 10.8.0.2 -p tcp -m tcp --dport 31408 -j SNAT --to-source 10.8.0.1
iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -d 10.8.0.2 -p tcp -m tcp --dport 31409 -j SNAT --to-source 10.8.0.1
